package com.shoping.web.advice;

import com.shoping.common.advice.AbstractExceptionHandler;
import com.shopping.alarm.ding.DingTalkTextMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice(basePackages = "com.shoping.web.controller")
public class GlobalExceptionHandler extends AbstractExceptionHandler {

    @Autowired
    DingTalkTextMessage dingTalkTextMessage;

    @Override
    public void sendOnOffMessage(String loggerMessage) {
        dingTalkTextMessage.sendText(loggerMessage);
    }

    @Override
    public void sendOnOffMessage(String loggerMessage, Throwable e) {
        dingTalkTextMessage.sendText(loggerMessage);
    }

    @Override
    public void sendErrorMsg(String loggerMessage, Throwable e) {
        dingTalkTextMessage.sendTextExMsg(e, loggerMessage);
    }

    @Override
    public void sendErrorMsg(String loggerMessage) {
        dingTalkTextMessage.sendText(loggerMessage);
    }
}
